import { request } from "../request";

/**
 * 重置用户密码接口返回结构
 */
export interface ResetPasswordRes {
    code: number;
    message: string;
    data: string;
    timestamp: Record<string, unknown>;
}

/**
 * 重置用户密码
 * @param id 用户ID
 * @param newPassword 新密码
 * @returns 重置结果
 */
export const resetPasswordAPI = async (id: number, newPassword: string): Promise<ResetPasswordRes> => {
    const token = localStorage.getItem("token");
    return request(`/api/users/${id}/reset-password?newPassword=${encodeURIComponent(newPassword)}`, {
        method: "put",
        headers: {
            Authorization: `Bearer ${token}`
        }
    });
};